<app-toolbar>
    <app-search-form placeholder="请输入ID"
        (onSearch)="search($event)"></app-search-form>
    <app-batch-btn [showAddBtn]="false"
        [showExportBtn]="false"
        [showImportBtn]="false"
        (batchDel)="handleBatchDel()"></app-batch-btn>
</app-toolbar>

<ng-template #totalTemplate
    let-total>总共 {{ total }} 条</ng-template>
<nz-table #basicTable
    [nzData]="datum"
    [nzFrontPagination]="false"
    [nzLoading]="loading"
    nzShowPagination
    [nzTotal]="total"
    nzShowSizeChanger
    [nzShowTotal]="totalTemplate"
    (nzPageSizeChange)="pageSizeChange($event)"
    (nzPageIndexChange)="pageIndexChange($event)"
    [nzPageSize]="pageSize"
    [nzPageIndex]="pageIndex"
    (nzQueryParams)="onQuery($event)">
    <thead>
        <tr>
            <th [nzChecked]="checked"
                [nzIndeterminate]="indeterminate"
                (nzCheckedChange)="handleAllChecked($event)"></th>
            <th nzColumnKey="id"
                [nzSortFn]="true">ID</th>
            <th nzColumnKey="alarm_id">报警ID</th>
            <th nzColumnKey="user_id">用户</th>
            <th nzColumnKey="channels">通道</th>
            <th nzColumnKey="created"
                [nzSortFn]="true">日期</th>
            <th>操作</th>
        </tr>
    </thead>
    <tbody>
        <tr *ngFor="let data of basicTable.data; let i = index">
            <td [nzChecked]="setOfCheckedId.has(data.id)"
                (nzCheckedChange)="handleItemChecked(data.id, $event)"></td>
            <td>{{ data.id }}</td>
            <td>{{ data.alarm_id }}</td>
            <td>{{ data.user || data.user_id }}</td>
            <td>{{ data.channels }}</td>
            <td>{{ data.created | date }}</td>
            <td>
                <a (click)="delete(data.id)">
                    <i nz-icon
                        nzType="delete"></i>
                </a>
            </td>
        </tr>
    </tbody>
</nz-table>
